<extend name="common:commonTemplate" />
<block name="main_content">
<div id="content">
	<div id="content-header">
		<div id="breadcrumb">
			<a class="tip-bottom" href="index.html"
				data-original-title="Go to Home"><i class="icon-home"></i> 首页</a> <a
				href="#">订单</a> <a class="current" href="#">推广订单详情</a>
		</div>

	</div>
	<div class="container-fluid">
		<div class="row-fluid">
			<div class="span6">
				<div class="widget-box">
					<div class="widget-title">
						<span class="icon"> <i class="icon-info-sign"></i>
						</span>
						<h5>推广订单详情</h5>

						<span style="float:right;padding-top:3px;padding-right:3px;">
								<a id="btnOrderReciveGoods" class="btn btn-primary" href="#">确认订单已完成</a>
						</span>

					</div>
					<div class="widget-content nopadding">
						<form novalidate="novalidate" id="basic_validate"
							name="basic_validate" action="#" method="post"
							class="form-horizontal">
							<div class="control-group">
								<label class="control-label">订单编号：</label><label
									style="text-align: left;" class="control-label"><span id="order_id">{$promoterOrder_en.order_id}</span></label>
							</div>
							<div class="control-group">
								<label class="control-label">推广人编号：</label><label
									style="text-align: left;" class="control-label">{$promoterOrder_en.promoter_id}</label>
							</div>
							<div class="control-group">
								<label class="control-label">推广人姓名：</label><label
									style="text-align: left;" class="control-label">{$promoterOrder_en.promoter_name}</label>
							</div>
							<div class="control-group">
								<label class="control-label">订单状态：</label><label
									style="text-align: left;" class="control-label">{$promoterOrder_en.order_status_text}</label>
							</div>
							<div class="control-group">
								<label class="control-label">订单分成状态：</label><label
									style="text-align: left;" class="control-label">{$promoterOrder_en.order_revenue_status_text}</label>
							</div>
							<div class="control-group">
								<label class="control-label">订单支付状态：</label><label
									style="text-align: left;" class="control-label">{$promoterOrder_en.payment_status_text}</label>
							</div>
							<div class="control-group">
								<label class="control-label">订单金额：</label><label
									style="text-align: left;" class="control-label">{$promoterOrder_en.order_amount}</label>
							</div>
							<div class="control-group">
								<label class="control-label">订单分成金额：</label><label
									style="text-align: left;" class="control-label">{$promoterOrder_en.revenue_amount}</label>
							</div>
							<div class="control-group">
								<label class="control-label">订单时间：</label><label
									style="text-align: left;" class="control-label">{$promoterOrder_en.order_date}</label>
							</div>
							<div class="control-group">
								<label class="control-label">订单完成时间：</label><label
									style="text-align: left;" class="control-label">{$promoterOrder_en.order_end_date}</label>
							</div>
							<div class="form-actions">
								<a target="_blank"
									href="{$ServerConfig.UrlConfig.order_whaleyinfo_site}order/orderdetail?order_id={$promoterOrder_en.order_id}"
									class="btn btn-primary">查看订单详情</a>
								<a id="cancelOrder"  href="javascript:void(0);" 
								class="btn btn-danger" 
								style="float:right">取消订单</a>
							</div>
							<div class="form-actions"></div>
						</form>
					</div>
				</div>
			</div>


			<div class="span6">
				<div class="widget-box">
					<div class="widget-title">
						<span class="icon"> <i class="icon-th"></i>
						</span>
						<h5>
							订单<span style="color: red">{$promoterOrder_en.order_id}</span> 分成明细
						</h5>
					</div>
					<div class="widget-content nopadding">
						<table class="table table-bordered table-striped"
							id="search_result" page_index="1">
							<thead>
								<tr>
									<th>推广人编号</th>
									<th>推广人姓名</th>
									<th>推广人类型</th>
									<th>商品名称</th>
									<th>商品数量</th>
									<th>分成类型</th>
									<th>分成标准<br/>金额</th>
									<th>实际分成金额<br/>（标准金额*数量）</th>
								</tr>
							</thead>
							<tbody>
								<volist id="promoter_order_revenue_detail_en" name="lst_promoter_order_revenue_detail_en">
								<tr class="odd gradeX">
									<td>{$promoter_order_revenue_detail_en.promoter_id}</td>
									<td>{$promoter_order_revenue_detail_en.promoter_name}</td>
									<td>{$promoter_order_revenue_detail_en.promoter_type_text}</td>
									<td style="width:200px;">{$promoter_order_revenue_detail_en.style_name}</td>
									<td>{$promoter_order_revenue_detail_en.qty}</td>
									<td>{$promoter_order_revenue_detail_en.revenue_type_text}</td>
									<td>{$promoter_order_revenue_detail_en.revenue_base_amount}</td>
									<td>{$promoter_order_revenue_detail_en.revenue_amount}</td>
								</tr>
								</volist>
							</tbody>
						</table>
					</div>
				</div>
			</div>


		</div>

	</div>



</div>
</block>

<block name="js_content"> <script>

var payment_status = {$promoterOrder_en.payment_status};
OrderDetailPage = {
	'BindEvent': function(){
		//取消订单
		$('#cancelOrder').bind('click', function(){
			if(payment_status == 1){
				if(!confirm('该订单已支付，确认取消么？')){
					return;
				}
			}
			OrderDetailPage.CancelOrder();	
		});


		//确认完成订单
		$('#btnOrderReciveGoods').bind('click', function(){
			if(confirm("您将使这张订单变为【已完成】状态，确认么？")){
				var order_id = $('#order_id').text();
				var docHeight = document.documentElement.clientHeight;
				layer.open({
					type: 2,
					title: '确认完成订单',
					fix: true,
					shadeClose: true,
					maxmin: true,
					offset:[(docHeight/2-240)+'px' , ''],
					area : ['auto','450px'],
					content: '/Order/OrderReciveGoodsAction?order_id=' + order_id,
					end: function(){
						window.location.reload();
					}
				});
			}
		});

	},
	'CancelOrder':function(){
		var order_id = $('#order_id').text()
		var result = OrderService.CancelOrder(order_id);

		if(result.IsSuccess == 0){
			alert(result.ErrorMsg);
			return;
		}
		else{
			alert('取消成功！');
			location.reload();
		}
	},
};
$(document).ready(function(){
	OrderDetailPage.BindEvent();
});
</script> </block>